      module mo_sim_dat
      private
      public :: set_sim_dat
      contains
      subroutine set_sim_dat
      use chem_mods, only : clscnt, cls_rxt_cnt, clsmap, permute, adv_mass, fix_mass
      use chem_mods, only : diag_map
      use chem_mods, only : phtcnt, rxt_tag_cnt, rxt_tag_lst, rxt_tag_map
      use chem_mods, only : pht_alias_lst, pht_alias_mult
      use chem_mods, only : het_lst, extfrc_lst, inv_lst, slvd_lst
      use abortutils, only : endrun
      use mo_tracname, only : solsym
      use chem_mods, only : frc_from_dataset
      use shr_kind_mod,only : r8 => shr_kind_r8
      use cam_logfile, only : iulog
      implicit none
!--------------------------------------------------------------
! ... local variables
!--------------------------------------------------------------
      integer :: ios
      clscnt(:) = (/ 8 , 0 , 0 , 95 , 0 /)
      cls_rxt_cnt(:,1) = (/ 30 , 12 , 0 , 8 /)
      cls_rxt_cnt(:,4) = (/ 2 , 65 , 144 , 95 /)
      solsym(:103) = (/ 'O3      ','O       ','O1D     ','N2O     ','NO      ', &
                        'NO2     ','NO3     ','HNO3    ','HO2NO2  ','N2O5    ', &
                        'H2      ','OH      ','HO2     ','H2O2    ','CH4     ', &
                        'CO      ','CH3O2   ','CH3OOH  ','CH2O    ','CH3OH   ', &
                        'C2H5OH  ','C2H4    ','EO      ','EO2     ','CH3COOH ', &
                        'GLYALD  ','C2H6    ','C2H5O2  ','C2H5OOH ','CH3CHO  ', &
                        'CH3CO3  ','CH3COOOH','C3H6    ','C3H8    ','C3H7O2  ', &
                        'C3H7OOH ','PO2     ','POOH    ','CH3COCH3','RO2     ', &
                        'ROOH    ','BIGENE  ','ENEO2   ','MEK     ','MEKO2   ', &
                        'MEKOOH  ','BIGALK  ','ALKO2   ','ALKOOH  ','ISOP    ', &
                        'ISOPO2  ','ISOPOOH ','MVK     ','MACR    ','MACRO2  ', &
                        'MACROOH ','MCO3    ','HYDRALD ','HYAC    ','CH3COCHO', &
                        'XO2     ','XOOH    ','C10H16  ','TERPO2  ','TERPOOH ', &
                        'TOLUENE ','CRESOL  ','TOLO2   ','TOLOOH  ','XOH     ', &
                        'BIGALD  ','GLYOXAL ','PAN     ','ONIT    ','MPAN    ', &
                        'ISOPNO3 ','ONITR   ','CB1     ','CB2     ','OC1     ', &
                        'OC2     ','SOA     ','SO2     ','DMS     ','SO4     ', &
                        'NH3     ','NH4     ','NH4NO3  ','SSLT01  ','SSLT02  ', &
                        'SSLT03  ','SSLT04  ','DST01   ','DST02   ','DST03   ', &
                        'DST04   ','Rn      ','Pb      ','HCN     ','CH3CN   ', &
                        'C2H2    ','HCOOH   ','HOCH2OO ' /)
      adv_mass(:103) = (/ 47.99820_r8, 15.99940_r8, 15.99940_r8, 44.01288_r8, 30.00614_r8, &
                          46.00554_r8, 62.00494_r8, 63.01234_r8, 79.01174_r8, 108.0105_r8, &
                          2.014800_r8, 17.00680_r8, 33.00620_r8, 34.01360_r8, 16.04060_r8, &
                          28.01040_r8, 47.03200_r8, 48.03940_r8, 30.02520_r8, 32.04000_r8, &
                          46.06580_r8, 28.05160_r8, 61.05780_r8, 77.05720_r8, 60.05040_r8, &
                          60.05040_r8, 30.06640_r8, 61.05780_r8, 62.06520_r8, 44.05100_r8, &
                          75.04240_r8, 76.04980_r8, 42.07740_r8, 44.09220_r8, 75.08360_r8, &
                          76.09100_r8, 91.08300_r8, 92.09040_r8, 58.07680_r8, 89.06820_r8, &
                          90.07560_r8, 56.10320_r8, 105.1088_r8, 72.10260_r8, 103.0940_r8, &
                          104.1014_r8, 72.14380_r8, 103.1352_r8, 104.1426_r8, 68.11420_r8, &
                          117.1198_r8, 118.1272_r8, 70.08780_r8, 70.08780_r8, 119.0934_r8, &
                          120.1008_r8, 101.0792_r8, 100.1130_r8, 74.07620_r8, 72.06140_r8, &
                          149.1186_r8, 150.1260_r8, 136.2284_r8, 185.2340_r8, 186.2414_r8, &
                          92.13620_r8, 108.1356_r8, 173.1406_r8, 174.1480_r8, 190.1474_r8, &
                          98.09820_r8, 58.03560_r8, 121.0479_r8, 119.0743_r8, 147.0847_r8, &
                          162.1179_r8, 147.1259_r8, 12.01100_r8, 12.01100_r8, 12.01100_r8, &
                          12.01100_r8, 144.1320_r8, 64.06480_r8, 62.13240_r8, 96.06360_r8, &
                          17.02894_r8, 18.03634_r8, 80.04128_r8, 58.44247_r8, 58.44247_r8, &
                          58.44247_r8, 58.44247_r8, 135.0640_r8, 135.0640_r8, 135.0640_r8, &
                          135.0640_r8, 222.0000_r8, 207.2000_r8, 27.02514_r8, 41.05094_r8, &
                          26.03680_r8, 46.02460_r8, 63.03140_r8 /)
      fix_mass(: 4) = (/ 0.00000000_r8, 28.0134792_r8, 31.9988003_r8, 18.0142002_r8 /)
      clsmap(: 8,1) = (/ 15, 4, 16, 97, 98, 11, 99, 100 /)
      clsmap(: 95,4) = (/ 1, 3, 2, 5, 6, 7, 8, 9, 10, 12, &
                            13, 14, 17, 18, 19, 20, 21, 22, 23, 24, &
                            25, 26, 27, 28, 29, 30, 31, 32, 33, 34, &
                            35, 36, 37, 38, 39, 40, 41, 42, 43, 47, &
                            48, 49, 44, 45, 46, 50, 51, 52, 53, 54, &
                            55, 56, 57, 58, 59, 60, 61, 62, 63, 64, &
                            65, 66, 67, 68, 69, 70, 71, 72, 73, 74, &
                            75, 76, 77, 83, 84, 85, 86, 87, 88, 82, &
                            78, 79, 80, 81, 101, 102, 103, 89, 90, 91, &
                            92, 93, 94, 95, 96 /)
      permute(: 95,4) = (/ 91, 30, 59, 88, 93, 94, 58, 41, 31, 89, &
                             90, 26, 92, 43, 82, 62, 33, 38, 27, 45, &
                             50, 63, 18, 71, 42, 76, 95, 49, 75, 19, &
                             72, 40, 67, 52, 68, 78, 34, 20, 35, 21, &
                             70, 65, 51, 66, 36, 74, 86, 61, 84, 80, &
                             85, 37, 87, 44, 79, 81, 83, 28, 64, 77, &
                             53, 23, 24, 55, 46, 29, 56, 54, 57, 47, &
                             60, 69, 73, 22, 32, 1, 17, 2, 3, 4, &
                              5, 6, 7, 8, 25, 39, 48, 9, 10, 11, &
                             12, 13, 14, 15, 16 /)
      diag_map(: 95) = (/ 1, 2, 3, 4, 5, 7, 8, 10, 11, 12, &
                            13, 14, 15, 16, 17, 18, 19, 21, 24, 27, &
                            30, 34, 36, 41, 44, 49, 52, 56, 59, 63, &
                            70, 75, 80, 84, 89, 96, 101, 106, 113, 116, &
                           121, 126, 131, 136, 140, 146, 152, 157, 163, 168, &
                           171, 176, 183, 190, 195, 203, 208, 215, 219, 225, &
                           233, 241, 246, 250, 260, 271, 279, 287, 292, 306, &
                           321, 331, 342, 352, 370, 383, 392, 404, 414, 420, &
                           430, 438, 451, 464, 482, 501, 517, 558, 634, 685, &
                           716, 746, 767, 801, 824 /)
      het_lst(:103) = (/ 'O3      ','O       ','O1D     ','N2O     ','NO      ', &
                         'NO2     ','NO3     ','HNO3    ','HO2NO2  ','N2O5    ', &
                         'H2      ','OH      ','HO2     ','H2O2    ','CH4     ', &
                         'CO      ','CH3O2   ','CH3OOH  ','CH2O    ','CH3OH   ', &
                         'C2H5OH  ','C2H4    ','EO      ','EO2     ','CH3COOH ', &
                         'GLYALD  ','C2H6    ','C2H5O2  ','C2H5OOH ','CH3CHO  ', &
                         'CH3CO3  ','CH3COOOH','C3H6    ','C3H8    ','C3H7O2  ', &
                         'C3H7OOH ','PO2     ','POOH    ','CH3COCH3','RO2     ', &
                         'ROOH    ','BIGENE  ','ENEO2   ','MEK     ','MEKO2   ', &
                         'MEKOOH  ','BIGALK  ','ALKO2   ','ALKOOH  ','ISOP    ', &
                         'ISOPO2  ','ISOPOOH ','MVK     ','MACR    ','MACRO2  ', &
                         'MACROOH ','MCO3    ','HYDRALD ','HYAC    ','CH3COCHO', &
                         'XO2     ','XOOH    ','C10H16  ','TERPO2  ','TERPOOH ', &
                         'TOLUENE ','CRESOL  ','TOLO2   ','TOLOOH  ','XOH     ', &
                         'BIGALD  ','GLYOXAL ','PAN     ','ONIT    ','MPAN    ', &
                         'ISOPNO3 ','ONITR   ','CB1     ','CB2     ','OC1     ', &
                         'OC2     ','SOA     ','SO2     ','DMS     ','SO4     ', &
                         'NH3     ','NH4     ','NH4NO3  ','SSLT01  ','SSLT02  ', &
                         'SSLT03  ','SSLT04  ','DST01   ','DST02   ','DST03   ', &
                         'DST04   ','Rn      ','Pb      ','HCN     ','CH3CN   ', &
                         'C2H2    ','HCOOH   ','HOCH2OO ' /)
      extfrc_lst(: 3) = (/ 'NO      ','CO      ','SO2     ' /)
      frc_from_dataset(: 3) = (/ .true., .true., .true. /)
      inv_lst(: 4) = (/ 'M       ', 'N2      ', 'O2      ', 'H2O     ' /)
      if( allocated( rxt_tag_lst ) ) then
         deallocate( rxt_tag_lst )
      end if
      allocate( rxt_tag_lst(rxt_tag_cnt),stat=ios )
      if( ios /= 0 ) then
         write(iulog,*) 'set_sim_dat: failed to allocate rxt_tag_lst; error = ',ios
         call endrun
      end if
      if( allocated( rxt_tag_map ) ) then
         deallocate( rxt_tag_map )
      end if
      allocate( rxt_tag_map(rxt_tag_cnt),stat=ios )
      if( ios /= 0 ) then
         write(iulog,*) 'set_sim_dat: failed to allocate rxt_tag_map; error = ',ios
         call endrun
      end if
      rxt_tag_lst(:rxt_tag_cnt) = (/ 'jo2             ', 'jo1d            ', 'jo3p            ', 'jn2o            ', &
                                     'jno2            ', 'jn2o5           ', 'jhno3           ', 'jno3_a          ', &
                                     'jno3_b          ', 'jho2no2_a       ', 'jho2no2_b       ', 'jch3ooh         ', &
                                     'jch2o_a         ', 'jch2o_b         ', 'jh2o2           ', 'jch3cho         ', &
                                     'jpooh           ', 'jch3co3h        ', 'jpan            ', 'jmpan           ', &
                                     'jmacr_a         ', 'jmacr_b         ', 'jmvk            ', 'jc2h5ooh        ', &
                                     'jc3h7ooh        ', 'jrooh           ', 'jacet           ', 'jmgly           ', &
                                     'jxooh           ', 'jonitr          ', 'jisopooh        ', 'jhyac           ', &
                                     'jglyald         ', 'jmek            ', 'jbigald         ', 'jglyoxal        ', &
                                     'jalkooh         ', 'jmekooh         ', 'jtolooh         ', 'jterpooh        ', &
                                     'usr_O_O2        ', 'o1d_n2          ', 'o1d_o2          ', 'ox_l1           ', &
                                     'ox_l2           ', 'ox_l3           ', 'usr_HO2_HO2     ', 'ox_p1           ', &
                                     'tag_NO2_NO3     ', 'usr_N2O5_M      ', 'tag_NO2_OH      ', 'usr_HNO3_OH     ', &
                                     'tag_NO2_HO2     ', 'usr_HO2NO2_M    ', 'ox_p2           ', 'usr_CO_OH_b     ', &
                                     'tag_C2H4_OH     ', 'ox_l6           ', 'ox_p16          ', 'ox_p5           ', &
                                     'ox_p4           ', 'tag_CH3CO3_NO2  ', 'usr_PAN_M       ', 'tag_C3H6_OH     ', &
                                     'ox_l4           ', 'ox_p3           ', 'ox_p9           ', 'usr_CH3COCH3_OH ', &
                                     'ox_p10          ', 'ox_p15          ', 'ox_p17          ', 'soa5            ', &
                                     'ox_p14          ', 'ox_l5           ', 'ox_p6           ', 'ox_l7           ', &
                                     'ox_l8           ', 'ox_p7           ', 'ox_p8           ', 'usr_MCO3_NO2    ', &
                                     'usr_MPAN_M      ', 'ox_p11          ', 'usr_XOOH_OH     ', 'soa4            ', &
                                     'ox_p12          ', 'soa2            ', 'soa1            ', 'soa3            ', &
                                     'ox_p13          ', 'usr_N2O5_aer    ', 'usr_NO3_aer     ', 'usr_NO2_aer     ', &
                                     'usr_SO2_OH      ', 'usr_DMS_OH      ', 'usr_HO2_aer     ' /)
      rxt_tag_map(:rxt_tag_cnt) = (/ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, &
                                       11, 12, 13, 14, 15, 16, 17, 18, 19, 20, &
                                       21, 22, 23, 24, 25, 26, 27, 28, 29, 30, &
                                       31, 32, 33, 34, 35, 36, 37, 38, 39, 40, &
                                       41, 43, 44, 45, 50, 51, 52, 59, 64, 65, &
                                       66, 67, 69, 71, 74, 82, 90, 91, 92, 96, &
                                      103, 104, 109, 115, 116, 118, 122, 126, 127, 136, &
                                      138, 142, 143, 147, 148, 159, 161, 162, 169, 175, &
                                      176, 180, 186, 187, 190, 193, 194, 195, 196, 200, &
                                      201, 202, 204, 206, 210 /)
      if( allocated( pht_alias_lst ) ) then
         deallocate( pht_alias_lst )
      end if
      allocate( pht_alias_lst(phtcnt,2),stat=ios )
      if( ios /= 0 ) then
         write(iulog,*) 'set_sim_dat: failed to allocate pht_alias_lst; error = ',ios
         call endrun
      end if
      if( allocated( pht_alias_mult ) ) then
         deallocate( pht_alias_mult )
      end if
      allocate( pht_alias_mult(phtcnt,2),stat=ios )
      if( ios /= 0 ) then
         write(iulog,*) 'set_sim_dat: failed to allocate pht_alias_mult; error = ',ios
         call endrun
      end if
      pht_alias_lst(:,1) = (/ '                ', '                ', '                ', '                ', &
                              '                ', '                ', '                ', '                ', &
                              '                ', '                ', '                ', '                ', &
                              '                ', '                ', '                ', '                ', &
                              '                ', '                ', '                ', '                ', &
                              '                ', '                ', '                ', '                ', &
                              '                ', '                ', '                ', '                ', &
                              '                ', '                ', '                ', '                ', &
                              '                ', '                ', '                ', '                ', &
                              '                ', '                ', '                ', '                ' /)
      pht_alias_lst(:,2) = (/ 'jo2_b           ', 'jo3_a           ', 'jo3_b           ', '                ', &
                              '                ', 'jn2o5_a         ', '                ', '                ', &
                              '                ', '                ', '                ', '                ', &
                              '                ', '                ', '                ', '                ', &
                              'jch3ooh         ', 'jh2o2           ', '                ', 'jpan            ', &
                              '                ', '                ', '                ', 'jch3ooh         ', &
                              'jch3ooh         ', 'jch3ooh         ', '                ', '                ', &
                              'jch3ooh         ', 'jch3cho         ', 'jch3ooh         ', '                ', &
                              '                ', 'jacet           ', 'jno2            ', 'jmgly           ', &
                              'jch3ooh         ', 'jch3ooh         ', 'jch3ooh         ', 'jch3ooh         ' /)
      pht_alias_mult(:,1) = (/ 1._r8, 1._r8, 1._r8, 1._r8, 1._r8, &
                          1._r8, 1._r8, 1._r8, 1._r8, 1._r8, &
                          1._r8, 1._r8, 1._r8, 1._r8, 1._r8, &
                          1._r8, 1._r8, 1._r8, 1._r8, 1._r8, &
                          1._r8, 1._r8, 1._r8, 1._r8, 1._r8, &
                          1._r8, 1._r8, 1._r8, 1._r8, 1._r8, &
                          1._r8, 1._r8, 1._r8, 1._r8, 1._r8, &
                          1._r8, 1._r8, 1._r8, 1._r8, 1._r8 /)
      pht_alias_mult(:,2) = (/ 1._r8, 1._r8, 1._r8, 1._r8, 1._r8, &
                          1._r8, 1._r8, 1._r8, 1._r8, 1._r8, &
                          1._r8, 1._r8, 1._r8, 1._r8, 1._r8, &
                          1._r8, 1._r8, .28_r8, 1._r8, 1._r8, &
                          1._r8, 1._r8, 1._r8, 1._r8, 1._r8, &
                          1._r8, 1._r8, 1._r8, 1._r8, 1._r8, &
                          1._r8, 1._r8, 1._r8, 1._r8, .2_r8, &
                          1._r8, 1._r8, 1._r8, 1._r8, 1._r8 /)
      end subroutine set_sim_dat
      end module mo_sim_dat
